package com.wangzh.data.arithmetic.sort;

import java.util.*;

public class ArrayTest {

    public static void main(String[] args) {
//        arrSort();

        int[]  aa  = new int[]{1,2,5,8};
        int i = Arrays.binarySearch(aa, 9);

        System.out.println(i);

        System.out.println(recursion(1));

        List<String> strs = new ArrayList<>();
        strs.add("a");
        strs.contains("a");
        Collection<String> strings = Collections.synchronizedCollection(strs);
        strings.add("b");

    }

    public static int recursion(int day){
        if (day <= 0 || day >= 11) {
            System.out.println("当前时间错误");
            return -1;
        }
        if (day==10) {
            return 1;
        }
        return (recursion(day+1)+1)*2;
    }
    private static void arrSort() {
        GirlFriend girlFriend = new GirlFriend("张三", 10, 1.78);
        GirlFriend girlFriend2 = new GirlFriend("李四", 9, 1.58);
        GirlFriend girlFriend3 = new GirlFriend("王五", 13, 1.88);
        GirlFriend girlFriend4 = new GirlFriend("张三2", 10, 1.98);
        GirlFriend girlFriend5 = new GirlFriend("张三1", 10, 1.98);

        GirlFriend[] arr = {girlFriend, girlFriend2, girlFriend3,girlFriend4,girlFriend5};
        //
        Arrays.sort(arr, new Comparator<GirlFriend>() {
            @Override
            public int compare(GirlFriend o1, GirlFriend o2) {
                double temp = o1.getAge() - o2.getAge();

                temp = temp == 0 ? o1.getHeight() - o2.getHeight() : temp;

                temp = temp == 0 ? o1.getName().compareTo(o2.getName()) : temp;

                if (temp > 0) {
                    return 1;
                } else if (temp < 0) {
                    return -1;
                } else {
                    return 0;
                }

            }
        });

        System.out.println(Arrays.toString(arr));
    }
}
